using System;
using System.Net;

namespace Neo4jRestSharp.Neo4jRestServices
{
	public static class Neo4jRequest
	{
		public static HttpWebRequest CreateWebRequest(string method, Uri uri)
		{
			return CreateWebRequest(method, uri, null);
		}

		public static HttpWebRequest CreateWebRequest(string method, Uri uri, UriQueryBuilder builder)
		{
			if (uri == null) throw new ArgumentNullException("uri");

			if (builder != null)
			{
				uri = builder.AddToUri(uri);
			}

			var httpWebRequest = (HttpWebRequest)WebRequest.Create(uri);
			httpWebRequest.Method = method;
			return httpWebRequest;
		}

		public static HttpWebRequest CreateJSONWebRequest(string method, Uri uri)
		{
			HttpWebRequest request = CreateWebRequest(method, uri);

			request.Accept = "application/json";

			return request;
		}
	}
}